/**
 * <copyright>
 * </copyright>
 *
 * $Id$
 */
package utn.frsf.cidisi.upcolbpip.b2bcollaborations.impl;

import java.util.Collection;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.common.util.EList;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.EObjectImpl;

import org.eclipse.emf.ecore.util.EObjectContainmentEList;
import org.eclipse.emf.ecore.util.InternalEList;

import utn.frsf.cidisi.upcolbpip.b2bcollaborations.B2bcollaborationsPackage;
import utn.frsf.cidisi.upcolbpip.b2bcollaborations.BusinessGoal;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Business Goal</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link utn.frsf.cidisi.upcolbpip.b2bcollaborations.impl.BusinessGoalImpl#getName <em>Name</em>}</li>
 *   <li>{@link utn.frsf.cidisi.upcolbpip.b2bcollaborations.impl.BusinessGoalImpl#getGoalDescription <em>Goal Description</em>}</li>
 *   <li>{@link utn.frsf.cidisi.upcolbpip.b2bcollaborations.impl.BusinessGoalImpl#getSubGoals <em>Sub Goals</em>}</li>
 *   <li>{@link utn.frsf.cidisi.upcolbpip.b2bcollaborations.impl.BusinessGoalImpl#getSuperGoal <em>Super Goal</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public abstract class BusinessGoalImpl extends EObjectImpl implements BusinessGoal {
	/**
	 * The default value of the '{@link #getName() <em>Name</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getName()
	 * @generated
	 * @ordered
	 */
	protected static final String NAME_EDEFAULT = null;

	/**
	 * The cached value of the '{@link #getName() <em>Name</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getName()
	 * @generated
	 * @ordered
	 */
	protected String name = NAME_EDEFAULT;

	/**
	 * The default value of the '{@link #getGoalDescription() <em>Goal Description</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getGoalDescription()
	 * @generated
	 * @ordered
	 */
	protected static final String GOAL_DESCRIPTION_EDEFAULT = null;

	/**
	 * The cached value of the '{@link #getGoalDescription() <em>Goal Description</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getGoalDescription()
	 * @generated
	 * @ordered
	 */
	protected String goalDescription = GOAL_DESCRIPTION_EDEFAULT;

	/**
	 * The cached value of the '{@link #getSubGoals() <em>Sub Goals</em>}' containment reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getSubGoals()
	 * @generated
	 * @ordered
	 */
	protected EList<BusinessGoal> subGoals;

	/**
	 * The cached value of the '{@link #getSuperGoal() <em>Super Goal</em>}' reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getSuperGoal()
	 * @generated
	 * @ordered
	 */
	protected BusinessGoal superGoal;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected BusinessGoalImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return B2bcollaborationsPackage.Literals.BUSINESS_GOAL;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public String getName() {
		return name;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setName(String newName) {
		String oldName = name;
		name = newName;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, B2bcollaborationsPackage.BUSINESS_GOAL__NAME, oldName, name));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public String getGoalDescription() {
		return goalDescription;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setGoalDescription(String newGoalDescription) {
		String oldGoalDescription = goalDescription;
		goalDescription = newGoalDescription;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, B2bcollaborationsPackage.BUSINESS_GOAL__GOAL_DESCRIPTION, oldGoalDescription, goalDescription));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<BusinessGoal> getSubGoals() {
		if (subGoals == null) {
			subGoals = new EObjectContainmentEList<BusinessGoal>(BusinessGoal.class, this, B2bcollaborationsPackage.BUSINESS_GOAL__SUB_GOALS);
		}
		return subGoals;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public BusinessGoal getSuperGoal() {
		if (superGoal != null && superGoal.eIsProxy()) {
			InternalEObject oldSuperGoal = (InternalEObject)superGoal;
			superGoal = (BusinessGoal)eResolveProxy(oldSuperGoal);
			if (superGoal != oldSuperGoal) {
				if (eNotificationRequired())
					eNotify(new ENotificationImpl(this, Notification.RESOLVE, B2bcollaborationsPackage.BUSINESS_GOAL__SUPER_GOAL, oldSuperGoal, superGoal));
			}
		}
		return superGoal;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public BusinessGoal basicGetSuperGoal() {
		return superGoal;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setSuperGoal(BusinessGoal newSuperGoal) {
		BusinessGoal oldSuperGoal = superGoal;
		superGoal = newSuperGoal;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, B2bcollaborationsPackage.BUSINESS_GOAL__SUPER_GOAL, oldSuperGoal, superGoal));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
		switch (featureID) {
			case B2bcollaborationsPackage.BUSINESS_GOAL__SUB_GOALS:
				return ((InternalEList<?>)getSubGoals()).basicRemove(otherEnd, msgs);
		}
		return super.eInverseRemove(otherEnd, featureID, msgs);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case B2bcollaborationsPackage.BUSINESS_GOAL__NAME:
				return getName();
			case B2bcollaborationsPackage.BUSINESS_GOAL__GOAL_DESCRIPTION:
				return getGoalDescription();
			case B2bcollaborationsPackage.BUSINESS_GOAL__SUB_GOALS:
				return getSubGoals();
			case B2bcollaborationsPackage.BUSINESS_GOAL__SUPER_GOAL:
				if (resolve) return getSuperGoal();
				return basicGetSuperGoal();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@SuppressWarnings("unchecked")
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case B2bcollaborationsPackage.BUSINESS_GOAL__NAME:
				setName((String)newValue);
				return;
			case B2bcollaborationsPackage.BUSINESS_GOAL__GOAL_DESCRIPTION:
				setGoalDescription((String)newValue);
				return;
			case B2bcollaborationsPackage.BUSINESS_GOAL__SUB_GOALS:
				getSubGoals().clear();
				getSubGoals().addAll((Collection<? extends BusinessGoal>)newValue);
				return;
			case B2bcollaborationsPackage.BUSINESS_GOAL__SUPER_GOAL:
				setSuperGoal((BusinessGoal)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case B2bcollaborationsPackage.BUSINESS_GOAL__NAME:
				setName(NAME_EDEFAULT);
				return;
			case B2bcollaborationsPackage.BUSINESS_GOAL__GOAL_DESCRIPTION:
				setGoalDescription(GOAL_DESCRIPTION_EDEFAULT);
				return;
			case B2bcollaborationsPackage.BUSINESS_GOAL__SUB_GOALS:
				getSubGoals().clear();
				return;
			case B2bcollaborationsPackage.BUSINESS_GOAL__SUPER_GOAL:
				setSuperGoal((BusinessGoal)null);
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case B2bcollaborationsPackage.BUSINESS_GOAL__NAME:
				return NAME_EDEFAULT == null ? name != null : !NAME_EDEFAULT.equals(name);
			case B2bcollaborationsPackage.BUSINESS_GOAL__GOAL_DESCRIPTION:
				return GOAL_DESCRIPTION_EDEFAULT == null ? goalDescription != null : !GOAL_DESCRIPTION_EDEFAULT.equals(goalDescription);
			case B2bcollaborationsPackage.BUSINESS_GOAL__SUB_GOALS:
				return subGoals != null && !subGoals.isEmpty();
			case B2bcollaborationsPackage.BUSINESS_GOAL__SUPER_GOAL:
				return superGoal != null;
		}
		return super.eIsSet(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public String toString() {
		if (eIsProxy()) return super.toString();

		StringBuffer result = new StringBuffer(super.toString());
		result.append(" (name: ");
		result.append(name);
		result.append(", goalDescription: ");
		result.append(goalDescription);
		result.append(')');
		return result.toString();
	}

} //BusinessGoalImpl
